#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;

void GetNext(vector<int>& next,const string& pattern)
{
	int i = 2;
	int k = 0;
	for (; i < pattern.size(); )
	{
		if (k == -1 || pattern[i - 1] == pattern[k])
		{
			next[i++] = ++k;
		}
		else
		{
			k = next[k];
		}
	}
}

int kmp(const string& text, const string& pattern)
{
	int lent = text.size();
	int lenp = pattern.size();
	if (lent * lenp == 0)return -1;
	if (lenp > lent)return -1;
	vector<int>next(pattern.size(), 0);
	next[0] = -1;
	GetNext(next, pattern);

	int i = 0, j = 0;
	while (i < lent && j < lenp)
	{
		if (j == -1 || text[i] == pattern[j])
		{
			++i, ++j;
		}
		else
		{
			j = next[j];
		}
	}
	if (j == pattern.size())
		return i - j;
	return -1;
}

int main() 
{

	string text, pattern;
	while (cin >> text >> pattern)
	{
		int index = kmp(text, pattern);
		if (index >= 0)
		{
			cout << index << " : " << text.substr(index, pattern.size())<<endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	return 0;
}